package uk.co.q3c.deplan.client.dao;

import java.util.Map;
import java.util.TreeMap;

import uk.co.q3c.deplan.client.domain.dag.DAG;

import com.googlecode.objectify.Key;

public class Cache {

	private Map<Key<?>, Object> cache;

	public Cache() {
		super();
		cache = new TreeMap<Key<?>, Object>();
	}

	public void add(DAG<?> dependencies) {
		cache.put(dependencies.getKey(), dependencies);
	}

	@SuppressWarnings("unchecked")
	public <T extends Object> T get(Key<T> key) {
		T entry = (T) cache.get(key);
		return entry;
	}
}
